package com.mezz.bones.im.common.exception;

import com.mezz.bones.im.common.enums.ActionCodeEnum;
import com.mezz.bones.im.common.result.ImResultCode;
import lombok.Getter;

@Getter
public class ImBaseException extends RuntimeException{

    private static final long serialVersionUID = 1223536604890537333L;
    private String code;
    private String msg;
    private ImResultCode resultCode;
    private Object data;
    private ActionCodeEnum actionCode = ActionCodeEnum.SERVER_ERROR;

    public ImBaseException(String msg) {
        super(msg);
        this.resultCode = ImResultCode.SYS_ERROR;
        this.msg = resultCode.getMessage();
        this.code = resultCode.getCode();
    }

    public ImBaseException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public ImBaseException(ImResultCode resultCode, String msg) {
        super(msg);
        this.resultCode = resultCode;
        this.code = resultCode.getCode();
        this.msg = msg;
    }

    public ImBaseException(ImResultCode resultCode) {
        super(resultCode.getMessage());
        this.resultCode = resultCode;
        this.code = resultCode.getCode();
        this.msg = resultCode.getMessage();
    }
}
